package top.ljjapp.aspect;/**
 * @FileName: TimeAspect.java
 * @Package: top.ljjapp.aspect
 * @Author: lijiajun
 * <br/>
 * @Created: 2018/11/21 13:44
 */

import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.springframework.stereotype.Component;

import java.util.Date;

/**
 * <p></p>
 * <p/>
 * <PRE>
 * <BR> 修改记录
 * <BR>-----------------------------------------------
 * <BR> 修改日期 修改人 修改内容
 * </PRE>
 *
 * @author lijiajun
 */
@Aspect
@Component
@Slf4j
public class TimeAspect {

//    @Around("execution(* top.ljjapp.controller.UserController.*(..))")
    public Object handleControllerMethod(ProceedingJoinPoint pjp) throws Throwable{
        log.info("timeAspect 切片开始");
        Object[] args = pjp.getArgs();
        for (Object arg : args){
            System.out.println("切片获取到方法的参数：" + arg);
        }
        long start = new Date().getTime();
        //切入点方法执行
        Object proceed = pjp.proceed();
        log.info("切片耗时h：" + (new Date().getTime() - start ));

        return proceed;
    }
}